/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package inet.dao;

import inet.entity.Position;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author MiSoKo
 */
public class PositionDAO extends BaseDAO {

    //Cập nhập
    public boolean updatePosition(Position position) {
        Connection conn = null;
        PreparedStatement ps = null;
        try {
            conn = getConnection();
            String sql = "UPDATE POSITION SET COM_ID = ?, COM_POSITION = ?, "
                    + "BRANCH_ID = ?, BRANCH_POSITION = ?, DEP_ID = ?, DEP_POSITION = ? "
                    + "WHERE EMP_ID = ?";
            ps = conn.prepareStatement(sql);
            int i = 1;
            ps.setBigDecimal(i++, position.getCom_id());
            ps.setString(i++, position.getCom_position());
            ps.setBigDecimal(i++, position.getBranch_id());
            ps.setString(i++, position.getBranch_position());
            ps.setBigDecimal(i++, position.getDep_id());
            ps.setString(i++, position.getDep_position());
            ps.setBigDecimal(i++, position.getEmp_id());
            return ps.executeUpdate() == 1;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            releaseConnection(conn, ps);
        }
        return false;
    }

//    public int empID() {
//        Connection conn = null;
//        PreparedStatement ps = null;
//        ResultSet rs = null;
//        String sql = null;
//
//        try {
//            sql = "SELECT MAX(EMP_ID)+1 AS EMPID FROM EMPLOYEE ";
//            conn = getConnection();
//            ps = conn.prepareStatement(sql);
//            rs = ps.executeQuery();
//            if (rs.next()) {
//                return rs.getInt(1);
//            }
//        } catch (Exception ex) {
//            System.out.println("Error in sql: " + sql);
//            ex.printStackTrace();
//        } finally {
//            releaseConnection(conn, ps, rs);
//        }
//        return 0;
//    }

//
//        public static void main(String[] a) {
//        Position emp = null;
//        emp = new Position();
//        PositionDAO d = new PositionDAO();
//        System.out.print(d.empID());
//    }
}
